package com.sfjswl.fp.core.utils;


import com.sfjswl.fp.common.enums.NodeRunStateEnum;
import com.sfjswl.fp.core.base.BaseNode;

public final class ProcessUtils {

  private ProcessUtils() {
  }

  public static void collectInfo(StringBuilder sb, BaseNode node, long start, NodeRunStateEnum stateEnum) {
    char state;
    switch (stateEnum) {
      case FALSE:
        state = 'F';
        break;
      case TRUE:
        state = 'T';
        break;
      case NONE:
        state = 'N';
        break;
      case SHUT_DOWN:
        state = 'S';
        break;
      default:
        state = '?';
        break;
    }
    synchronized (sb) {
      sb.append('[').append(node.getRuleNodeId()).append(':').append(node.getRuleLogName()).append(':')
        .append(state).append(':').append(System.currentTimeMillis() - start)
        .append(']');
    }
  }

  public static void collectInfo(StringBuilder sb, BaseNode node, char state) {
    synchronized (sb) {
      sb.append('[').append(node.getRuleNodeId()).append(':').append(node.getRuleLogName()).append(':')
        .append(state).append(']');
    }
  }
}

